package com.team.controller;

import com.team.entity.News;
import com.team.service.NewsUpAndDownService;
import com.team.vo.Result;
import com.team.vo.SearchContent;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author keluoyisi
 * @program: seven
 * @description: 上下文控制层
 * @date 2022-10-18 00:45:44
 */
@Controller
@ResponseBody
@RequestMapping("/NewsUpAndDown")
public class NewsUpAndDown {
    @Autowired
    private NewsUpAndDownService newsUpAndDownService;

    /**
     * @param :
     * @return Result
     * @description 获取全部的新闻
     */
    @RequestMapping("/selectAllNews")
    public Result selectAllNews(@RequestParam(defaultValue = "1") int currentPage, @RequestParam(defaultValue = "5") int pageSize, @RequestBody SearchContent searchContent){
        return newsUpAndDownService.selectAllNews(currentPage,pageSize,searchContent);
    }

    /**
     * @param id:
     * @param status:
     * @return Result
     * @description 修改新闻的上下架
     */
    @RequestMapping("/upUpdate")
    public Result upUpdate(@Param("id") int id,@Param("status") int status){
        System.out.println(id);
        System.out.println(status);
        return newsUpAndDownService.upUpdate(id,status);
    }

    /**
     * @param id:
     * @param uppid:
     * @return Result
     * @description 修改新闻的置顶和取消置顶
     */
    @RequestMapping("/topUpdate")
    public Result topUpdate(@RequestParam("id") int id,@RequestParam("uppid") int uppid){
        System.out.println(id);
        System.out.println(uppid);
        return newsUpAndDownService.topUpdate(id,uppid);
    }
}
